package br.com.dev.tcc.view.corretor;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;
import android.widget.TextView;
import br.com.dev.tcc.R;
import br.com.dev.tcc.adapter.ListaCorretoresAdapter;
import br.com.dev.tcc.bean.Corretor;

public class ListaCorretoresView {

	private Context ctx;
	private ListView list;
	private TextView tvNoItens;

	public ListaCorretoresView(Activity activity) {

		ctx = activity;
		list = (ListView) activity.findViewById(R.id.list);
		tvNoItens = (TextView) activity.findViewById(R.id.tvNoItens);
	}

	public void setItens(List<Corretor> itens) {

		list.setVisibility(View.VISIBLE);
		tvNoItens.setVisibility(View.GONE);
		list.setAdapter(new ListaCorretoresAdapter(ctx, itens));
	}

	public void setClickListener(OnItemClickListener listener) {

		list.setOnItemClickListener(listener);
	}
	
	public void setLongClickListener(OnItemLongClickListener listener) {

		list.setOnItemLongClickListener(listener);
	}

	public void hideList() {

		list.setVisibility(View.GONE);
		tvNoItens.setVisibility(View.VISIBLE);
	}
}
